import { formDate } from 'commonjs/formatDate.js'
const state = {
  wsData: []
}

const getters = {
  getData: state => state.wsData
}

const mutations = {
  set_data (context, data) {
    data.visited.map(valid => {
      valid.visitTime = formDate(valid.visitTime)
    })
    data.come_back_late.map(valid => {
      valid.BCLtime = formDate(valid.BCLtime)
    })
    context.wsData = data
  }
}
const actions = {
  // 获取ws传来的数据
  get_data (context, data) {
    context.commit('set_data', JSON.parse(data))
    // context.commit('set_data', data)
  }
}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
